package types;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;

import javax.sound.sampled.DataLine;

public class ImageData
{
	// constructors
	public ImageData(
	) {
		
	}
	public void initFromText(
			Reader dataReader
	) throws IOException {
		BufferedReader br = new BufferedReader( dataReader );
		final String delim = "\t";
		String l = br.readLine();
		String[] ls = l.split( delim );
		final int imgHeight = new Integer( ls[0] ).intValue();
		final int imgWidth = new Integer( ls[1] ).intValue();
		int[][] data = new int[imgHeight][imgWidth];
		for ( int r = 0; r < imgHeight; ++r )
		{
			int[] dataRow = data[r];
			l = br.readLine();
			ls = l.split( delim );
			for ( int c = 0; c < imgWidth; ++c )
				dataRow[c] = new Integer( ls[c] ).intValue();
		}
		
		this.imgData = data;
		this.imgHeight = imgHeight;
		this.imgWidth = imgWidth;
	}
	// ~constructors
	
	// getters
	public int imgWidth() { return this.imgWidth; }
	public int imgHeight() { return this.imgHeight; }
	public int[][] imgData() { return this.imgData; }
	// ~getters
	
	// fields
	private int imgHeight;
	private int imgWidth;
	private int[][] imgData;
	// ~fields
}
